#pragma once

#include <iostream>
#include <string>
#include "Protocol.hpp"

using namespace protocol_ns;

class CalCulate
{
public:
    Response calculate(const Request &req)
    {
        Response resp(0, 0);

        switch (req._oper)
        {
        case '+':
            resp._result = req._data_x + req._data_y;
            break;
        case '-':
            resp._result = req._data_x - req._data_y;
            break;
        case '*':
            resp._result = req._data_x + req._data_y;
            break;
        case '/':
        {
            if (req._data_y == 0)
            {
                resp._code = 1;
            }
            else
            {
                resp._result = req._data_x / req._data_y;
            }
        }
        break;
        case '%':
        {
            if (req._data_y == 0)
            {
                resp._code = 2;
            }
            else
            {
                resp._result = req._data_x % req._data_y;
            }
        }
        break;
        default:
            resp._code = 3;
            break;
        }
        return resp;
    }
};